<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 4.3.2 or newer
 *
 * @package		CodeIgniter
 * @author		ExpressionEngine Dev Team
 * @copyright	Copyright (c) 2008 - 2009, EllisLab, Inc.
 * @license		http://codeigniter.com/user_guide/license.html
 * @link		http://codeigniter.com
 * @since		Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * System Functions Class
 *
 * @package		CodeIgniter
 * @subpackage	Libraries
 * @category	Libraries
 * @author		Jiang
 */

class Myfunctions
{
	/**
	 * Constructor
	 * @access	public
	 */
	function Myfunctions()
	{
		$CI =& get_instance();
		$CI->form_validation->set_error_delimiters('<span class="tips10">', '</span>');
	}

	/**
	 * 检测用户登录
	 *
	 * 全局检测用户是否登录，如果没有登录跳转到登录页
	 *
	 * @access public
	 * @param	void
	 * @return void
	 */
	function check_user_login()
	{
		$this->CI =& get_instance();
		$this->CI->load->model('user/approve_model');
		$admin_status = $this->CI->approve_model->checkAdminStatus( $this->CI->session->userdata('adm_username') );

		if( !$this->CI->session->userdata('adm_username') || !$this->CI->session->userdata('adm_password') || !$admin_status)
		{
			redirect('/user/approve/login/');
		}
	}

	/**
	 * 通用 Select
	 *
	 * 通用下拉列表(数组)
	 *
	 * @access public
	 * @param	arrs
	 * @param	name
	 * @param	select_row
	 * @return Select
	 */
	function myselect($arrs, $name="select", $select_row="", $mult=false, $js="",$default='请选择')
	{
		$is_mult = !($mult) ? "" : " multiple=\"true\" ";
		$sel_name = ($mult==true) ? $name."[]" : $name;
		$id = $name;
		$sel_arr = @explode(",",$select_row);
		$select_com = "<select id='"._($id)."' name='".$sel_name."' ".$is_mult." ".$js.">";
		if(!empty($default)){
			$select_com .= "<option value=''>"._($default)."</option>";
		}
		foreach($arrs as $k=>$v)
		{
			$selected = ( in_array($k,$sel_arr) ) ? "selected" : "";
			$select_com .= "<option value='".$k."' ".$selected.">"._($v)."</option>";
		}

		$select_com .= "</select>";
		return $select_com;
	}

	/**
	 * 通用 Select
	 *
	 * 通用下拉列表(数据库)
	 *
	 * @access public
	 * @param	name
	 * @param	table
	 * @param	key
	 * @param	value
	 * @param	where
	 * @param	id
	 * @param	please_select
	 * @param	javascript
	 * @return Select
	 */
	function myselect2($name,$table,$key,$value,$where="",$id="",$please_select="",$js="", $mult=false,$style="combox_select")
	{
		$this->CI =& get_instance();
		$sel_name = ($mult==true) ? $name."[]" : $name;
		$sel_id = $name;
		$is_mult = !($mult) ? "" : " multiple=\"true\" class=\"".$style."\" ";
		$please_select = !$please_select ? _("请选择") : $please_select;
		$js = !$js ? "" : $js;
		$id = !$id ? $this->CI->input->post($name) : $id;
		$id_arr = @explode(",",$id);
		$select_com = "<select id='".$sel_id."' name='".$sel_name."' ".$is_mult." ".$js.">";
		$select_com .= "<option value=''>".$please_select."</option>";
		$query = $this->CI->db->query("select ".$key.",".$value." from ".$table." ".$where." order by '".$key."' ");

		$arr_key = explode(".",$key);
		$arr_value = explode(".",$value);
		$key = $arr_key[1]?$arr_key[1]:$arr_key[0];
		$value = $arr_value[1]?$arr_value[1]:$arr_value[0];

		foreach ($query->result() as $k=>$v)
		{
			$selected = @in_array($v->$key,$id_arr) ? "selected" : "";
			$select_com .= "<option value='".$v->$key."' ".$selected.">".$v->$value."</option>";
		}
		$select_com .= "</select>";
		return $select_com;
	}

	/**
	 * 通用 Select
	 *
	 * 通用下拉列表(数组) (js+css 版本)
	 *
	 * @access public
	 * @param	arrs
	 * @param	name
	 * @param	select_row
	 * @return Select
	 */
	function myselectUpgrade($arrs, $name="select", $select_row="",$div_style="", $mult=false, $js="",$default='请选择')
	{
		$is_mult = !($mult) ? "" : " multiple=\"true\" ";
		$sel_name = ($mult==true) ? $name."[]" : $name;
		$id = $name;
		$sel_arr = @explode(",",$select_row);
		$select_com = "<div ".$div_style .">";
		$select_com .= "<select id='"._($id)."' name='".$sel_name."' ".$is_mult." ".$js.">";
		if(!empty($default)){
			$select_com .= "<option value=''>"._($default)."</option>";
		}
		foreach($arrs as $k=>$v)
		{
			$selected = ( in_array($k,$sel_arr) ) ? "selected" : "";
			$select_com .= "<option value='".$k."' ".$selected.">"._($v)."</option>";
		}

		$select_com .= "</select></div>";
		return $select_com;
	}

	/**
	 * 通用 Radio
	 *
	 * 通用单选按钮(数据库)
	 *
	 * @access public
	 * @param	name
	 * @param	table
	 * @param	key
	 * @param	value
	 * @param	where
	 * @param	status
	 * @return Radio
	 */
	function radioSelect($name,$table,$key,$value,$where,$status="",$javascript="")
	{
		$this->CI =& get_instance();

		$radio_com = "";
		$query = $this->CI->db->query("select ".$key.",".$value." from ".$table." ".$where." order by '".$key."' ");
		foreach ($query->result() as $k=>$v)
		{
			$checked = ($v->$key == $status) ? " checked=\"checked\" " : "";
			$radio_com .= "<input type='radio' id='".$v->$key."' name='".$name."' value='".$v->$key."' ".$checked." ".$javascript."> <label for='".$v->$key."'>".$v->$value."</label> ";
		}
		return $radio_com;
	}

	/**
	 * 通用 Radio
	 *
	 * 通用单选按钮(数组)
	 *
	 * @access public
	 * @param	name
	 * @param	array
	 * @param	status
	 * @return Radio
	 */
	function radioSelect2($name,$array,$status="",$javascript="")
	{
		$radio = "";
		foreach($array as $key=>$value)
		{
			$checked = ($key==$status) ? " checked=\"checked\" " : "";
			$radio .= "<input type='radio' id='".$name."_".$key."' name='".$name."' value='".$key."' ".$checked." ".$javascript."> <label for='".$name."_".$key."'>"._($value)."</label> ";
		}
		return $radio;
	}

	/**
	 * 通用 Radio
	 *
	 * 通用单选按钮升级版(数组) 
	 *
	 * @access public
	 * @param	name
	 * @param	array
	 * @param	status
	 * @param	js
	 * @param	linecont
	 * @param	tr_class
	 * @param	td_class
	 * @return Radio
	 */
	function radioUpgrade($name,$array,$status="",$javascript="",$linecont="4",$tr_class='',$td_class='')
	{
		$i=0;
		$radio = "";
		foreach ($array as $k=>$v)
		{	
			$i++;
			$radio .= "<td class='".$td_class."'>";
			$checked = ($k==$status) ? " checked=\"checked\" " : "";
			$radio .= "<input type='radio' id='".$name."_".$k."' name='".$name."' value='".$k."' ".$checked." ".$javascript.">  <label for='".$name."_".$k."'>"._($v)."</label> ";
			$radio .= "</td>";
			if($i % $linecont == 0){
				$radio .= "</tr><tr class='".$tr_class."'>";
			}
		}
		return $radio;
	}

	/**
	 * 通用 checkbox
	 *
	 * 通用多选按钮(数据库)
	 *
	 * @access public
	 * @param	name
	 * @param	table
	 * @param	key
	 * @param	value
	 * @param	where
	 * @param	status
	 * @return Radio
	 */
	function checkboxSelect($name,$table,$key,$value,$where,$status="",$javascript="",$linecont="4",$table_class='',$tr_class='',$td_class='')
	{
		$this->CI =& get_instance();

		$checkbox_com = "<table class='".$table_class."'><tr class='".$tr_class."'>";
		$query = $this->CI->db->query("select ".$key.",".$value." from ".$table." ".$where." order by '".$key."' ");
		$arr_key = explode(".",$key);
		$arr_value = explode(".",$value);
		$key = $arr_key[1]?$arr_key[1]:$arr_key[0];
		$value = $arr_value[1]?$arr_value[1]:$arr_value[0];
		$i=0;
		foreach ($query->result() as $k=>$v)
		{	
			$i++;
			$checkbox_com .= "<td class='".$td_class."'>";
			if($status){
				$arr_status = explode(",",$status);
			}
			//$checked = ($v->$key == $status) ? " checked=\"checked\" " : "";
			$checked = (in_array($v->$key,$arr_status)) ? " checked=\"checked\" " : "";
			$checkbox_com .= "<input type='checkbox' id='".$name."_".$v->$key."' name='".$name."[]' value='".$v->$key."' ".$checked." ".$javascript."> <label for='".$name."_".$v->$key."'>".$v->$value."</label> ";
			$checkbox_com .= "</td>";
			if($i%$linecont == 0){
				$checkbox_com .= "</tr><tr class='".$tr_class."'>";
			}
		}
		$checkbox_com.="</tr></table>";
		return $checkbox_com;
	}

	/**
	 * 通用 checkbox
	 *
	 * 通用多选按钮(数组)
	 *
	 * @access public
	 * @param	name
	 * @param	array
	 * @param	status
	 * @return Radio
	 */
	function checkboxSelect2($name,$array,$status="",$javascript="")
	{
		$checkbox = "";
		foreach($array as $key=>$value)
		{
			if($status){
				$arr_status = explode(",",$status);
			}
			$checked = (in_array($key,$arr_status)) ? " checked=\"checked\" " : "";
			$checkbox .= "<input type='checkbox' id='".$name."_".$key."' name='".$name."[]' value='".$key."' ".$checked." ".$javascript."> <label for='".$name."_".$key."'>"._($value)."</label> ";
		}
		return $checkbox;
	}

	/**
	 * 通用 页面链接
	 *
	 * 通用页面链接(刷新,返回,etc.)
	 *
	 * @access public
	 * @param	code
	 * @return URL link
	 */
	function globalLink($code="refresh")
	{
		$this->CI =& get_instance();
		$global_links = $this->CI->config->item("global_links");
		if($code == "back" && !$this->CI->input->get("back_url"))
		{
			$link = "<a href='javascript:".$global_links[$code]['target']."' class='huise'>".$global_links[$code]['name']."</a>";
		}
		else
		{
			$link = anchor($global_links[$code]['target'],$global_links[$code]['name'],'class="huise"');
		}
		return $link;
	}

	/**
	* 创建多级目录
	*
	* 创建多级目录
	*
	* @access public
	* @param mkpath 创建目录的路径
	* @param mode 目录权限
	*/
	function mkpath($mkpath,$mode=0777)
	{
		$path_arr=explode('/',$mkpath);
		foreach ($path_arr as $value)
		{
			if(!empty($value)){
				if(empty($path))$path=$value;
				else $path.='/'.$value;
				is_dir($path) or mkdir($path,$mode);
			}
		}
	}

	/**
	* 载入站点文档，例如用户协议等
	*
	* 载入站点文档
	*
	* @access public
	* @param doc_type 文档类别,例如TOS
	*/
	function readDocument($doc_type)
	{
		$this->CI =& get_instance();

		//文档语言
		$doc_lang = !$this->CI->session->userdata('adm_lang') ? "zh_CN" : $this->CI->session->userdata('adm_lang');

		//读取文档
		$doc = read_file("./document/".$doc_type."/".$doc_type."_".$doc_lang.".txt");
		return !$doc ? false : $doc;
	}

	/**
	* 检测阿拉伯数字
	*
	* 仅允许输入阿拉伯数字
	*
	* @access public
	* @param numeric 参数
	*/
	function checkIsNumeric($numeric)
	{
		return !preg_match("/^(\-?)(\d+)$/",trim($numeric)) ? false : true;
	}

	/**
	* 检测非数字字符
	*
	* 仅允许输入非数字字符
	*
	* @access public
	* @param string 参数
	*/
	function checkIsString($string)
	{
		return !preg_match("/^(\-?)(\D+)$/",trim($string),$matches) ? false : true;
	}

	/**
	* 检测非数字与字母组合字符(附带中横杠,下划扛)
	*
	* 仅允许输入数字与字母组合字符(附带中横杠,下划扛)
	*
	* @access public
	* @param string 参数
	*/
	function checkIsStringAndNumericPlus($string)
	{
		return !preg_match("/^([_-a-zA-Z0-9])+$/i", $string) ? FALSE : TRUE;
	}

	/**
	* 检测手机号
	*
	* 检测手机号
	*
	* @access public
	* @param mobile 手机号
	*/
	function checkMobile($mobile)
	{
		return (!preg_match("/^(13|15|18)[0-9]{9}$/",trim($mobile))) ? false : true;
	}

	/**
	* 检测电话号码
	*
	* 检测电话号码
	*
	* @access public
	* @param phone 电话号码
	*/
	function checkPhone($phone)
	{
		return !preg_match("/^([0-9]|[-])+$/",trim($phone)) ? false : true;
	}

	/**
	* 检查URL格式
	*
	* 检查URL格式
	*
	* @access public
	* @param url URL地址
	*/
	function checkUrl($url) 
	{
		if (preg_match('/^(http|https):\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"])*$/',$url)) {
			return true;
		} else {
			return false;
		}
	}

	/**
	* 检查电子邮件格式
	*
	* 检查电子邮件格式
	*
	* @access public
	* @param email 电子邮件
	*/
	function checkEmail($email) 
	{
		return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $email)) ? FALSE : TRUE;
	}

	/**
	* 生成随机数
	*
	* 自动生成字母和数字混合随机数
	*
	* @access public
	* @param length 生成随机长度
	* @param mode 组合形态 0: 大小写字母和数字在组合; 1: 仅数字; 2: 仅小写字母; 3: 仅大写字母
	*/
	function getCode($length=8, $mode=0)
	{
		switch ($mode) {
			case '1':
			$str = '1234567890';
			break;
			case '2':
			$str = 'abcdefghijklmnopqrstuvwxyz';
			break;
			case '3':
			$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
			break;
			default:
			$str = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
			break;
		}

		$result = '';
		$l = strlen($str)-1;
		$num=0;

		for($i = 0;$i < $length;$i ++){
			$num = rand(0, $l);
			$a=$str[$num];
			$result =$result.$a;
		}
		return $result;
	}

	/**
	* 发送邮件
	*
	* 发送邮件
	*
	* @access public
	*/
	function sendmail($from,$fromname,$to,$subject,$msg,$cc="",$bcc="",$mailtype="text")
	{
		$this->CI =& get_instance();

		$this->CI->email->from($from, $fromname);
		$this->CI->email->to($to);
		if($cc){ $this->CI->email->cc($cc); }
		if($bcc){ $this->CI->email->bcc($bcc); }
		$this->CI->email->subject($subject);
		$this->CI->email->message($msg);
		return $this->CI->email->send();
	}

	/**
	* 短信接口
	*
	* 短信接口
	*
	* @access public
	* @param mobile 接收方手机号码
	* @param content 短信内容
	* @param id 本地记录流水号 组合形态 6位前置0数字
	*/
	function sendmsg($mobile,$content,$id)
	{
		$content = SMSUSERNAME."&".SMSPASSWORD."&".$id."&".$mobile."&".$content."&";
		$encrypt = $this->encrypt($content,SMSKEY);
		$sendsms = file("http://api.tosurveys.com/sms/gateway_sms.php?".base64_encode($encrypt));
		$status = explode('&',$sendsms[0]);
		return array_pop(explode('=',$status[0])) == "200" ? "OK" : false;
	}

	/**
	* 通用加密key
	*
	* 通用加密key
	*
	* @access public
	* @param txt 加密原文
	*/
	function keyED($txt)
	{
		$encrypt_key = strtoupper(md5(SMSKEY));
		$ctr=0;
		$tmp = "";
		for ($i=0;$i<strlen($txt);$i++)
		{
			if ($ctr==strlen($encrypt_key)) $ctr=0;
			$tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
			$ctr++;
		}
		return $tmp;
	}

	/**
	* 通用加密
	*
	* 通用加密
	*
	* @access public
	* @param txt 加密原文
	*/
	function encrypt($txt)
	{
		srand((double)microtime()*1000000);
		$encrypt_key = strtoupper(md5(rand(0,32000)));
		$ctr=0;
		$tmp = "";
		for ($i=0;$i<strlen($txt);$i++)
		{
			if ($ctr==strlen($encrypt_key)) $ctr=0;
			$tmp.= substr($encrypt_key,$ctr,1).(substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
			$ctr++;
		}
		return $this->keyED($tmp);
	}

	/**
	* 通用解密
	*
	* 通用解密
	*
	* @access public
	* @param txt 加密密文
	*/	
	function decrypt($txt)
	{
		$txt = $this->keyED($txt);
		$tmp = "";
		for ($i=0;$i<strlen($txt);$i++)
		{
			$md5 = substr($txt,$i,1);
			$i++;
			$tmp.= (substr($txt,$i,1) ^ $md5);
		}
		return $tmp;
	}

	/**
	* iPanel 项目链接加解密key
	*
	* iPanel 项目链接加解密key
	*
	* @access public
	* @param txt 加密原文
	*/
	function keyED_ipanel($txt,$encrypt_key)
	{
		$encrypt_key = "ABCDEFG";
		$ctr=0;
		$tmp = "";
		for ($i=0;$i<strlen($txt);$i++)
		{
			if ($ctr==strlen($encrypt_key)) $ctr=0;
			$tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
			$ctr++;
		}
		return $tmp;
	}

	/**
	* iPanel 项目链接加密
	*
	* iPanel 项目链接加密
	*
	* @access public
	* @param txt 加密原文
	* @param key 加密口令
	*/
	function encrypt_ipanel($txt,$key)
	{
		$encrypt_key = "ABCDEFG";
		$ctr=0;
		$tmp = "";
		for ($i=0;$i<strlen($txt);$i++)
		{
			if ($ctr==strlen($encrypt_key)) $ctr=0;
			$tmp.= substr($encrypt_key,$ctr,1).(substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
			$ctr++;
		}
		return $this->keyED_ipanel($tmp,$key);
	}

	/**
	* iPanel 项目链接解密
	*
	* iPanel 项目链接解密
	*
	* @access public
	* @param txt 密文
	* @param key 解密口令
	*/
	function decrypt_ipanel($txt, $key)
	{
		$txt = $this->keyED_ipanel($txt,$key);
		$tmp = "";
		for ($i=0;$i<strlen($txt);$i++)
		{
			$md5 = substr($txt,$i,1);
			$i++;
			$tmp.= (substr($txt,$i,1) ^ $md5);
		}
		return $tmp;
	}

	/**
	* 补位函数
	* 
	* 补位函数
	* @access public
	* @param str 原记录数字
	* @param location 1:前补位; 0:后补位
	* @param length 补位长度(重复数)
	* @param add 补位字符，如 "0"
	*/
	function add_zero($str,$location,$length,$add)
	{
		$add_zero = $length - strlen($str);
		if ($location == 1) {
			$str = str_repeat($add,$add_zero).$str;
		} else {
			$str .= str_repeat($add,$add_zero);
		}
		return $str;
	}

	/**
	* 自定义项目号
	* 
	* @access public
	* @param sys 系统号,int格式
	* @param pid 原项目号,int格式
	* @return fix_pid 自定义项目号,str格式(例如 P2000123)
	*/
	function cus_pid($sys,$pid,$flag="P")
	{
		$pid_tmp = $this->add_zero($pid,1,7,0);
		return $flag.$sys.$pid_tmp;
	}

	/**
	* 载入meta标签(网页编码)
	* 
	* 载入meta标签(网页编码)
	* @access public
	*/
	function loadMeta()
	{
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
	}

	/**	
	* 截取字符串
	*
	* 截取字符串
	* @access public
	*/
	function cut_str($string, $sublen, $start, $code)
	{
		if($code == 'UTF-8')
		{
			$pa = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/";
			preg_match_all($pa, $string, $t_string);

			if(count($t_string[0]) - $start > $sublen) return join('', array_slice($t_string[0], $start, $sublen))."...";
			return join('', array_slice($t_string[0], $start, $sublen));
		}
		else
		{
			$start = $start*2;
			$sublen = $sublen*2;
			$strlen = strlen($string);
			$tmpstr = '';

			for($i=0; $i< $strlen; $i++)
			{
				if($i>=$start && $i< ($start+$sublen))
				{
					if(ord(substr($string, $i, 1))>129)
					{
						$tmpstr.= substr($string, $i, 2);
					}
					else
					{
						$tmpstr.= substr($string, $i, 1);
					}
				}
				if(ord(substr($string, $i, 1))>129) $i++;
			}
			if(strlen($tmpstr)< $strlen ) $tmpstr.= "...";
			return $tmpstr;
		}
	}

	/**	
	* 生成 CSV 数据文件
	*
	* 生成 CSV 数据文件
	* @access public
	* @param file_name 导出的文件名
	* @param title 文件内容标题
	* @param headline 数据标题列
	* @param data 数据列
	*/
	function makeCSV($file_name,$title,$headline,$data)
	{
		set_time_limit(0);
		ini_set("display_errors",1);
		ini_set("memory_limit","1000M");

		header("Content-type: text/csv");  
		header("Content-type:application/csv;charset=UTF-8");
		header('Content-Disposition: attachment; filename="'.$file_name.'"');
		header("Pragma: no-cache");
		header("Expires: 0");
		$csv_file = "\xEF\xBB\xBF";
		//$csv_file .= iconv("UTF-8","GBK",implode(",",$headline))."\r\n";
		$csv_file .= $title."\r\n";
		$csv_file .= implode(",",$headline)."\r\n";
		if($data)
		{
			foreach($data as $k=>$v)
			{
				//$csv_file .= iconv("UTF-8","GBK",implode(",",$v))."\r\n";
				$csv_file .= implode(",",$v)."\r\n";
			}
		}
		echo $csv_file;
	}

	/**	
	* 生成 XSL 数据文件
	*
	* 生成 XSL 数据文件
	* @access public
	* @param file_name 导出的文件名
	* @param title 文件内容标题
	* @param headline 数据标题列
	* @param data 数据列
	*/
	function makeXSL($file_name,$title,$headline,$data)
	{
		set_time_limit(0);
		ini_set("display_errors",1);
		ini_set("memory_limit","1000M");

		$this->CI =& get_instance();

		//载入 Execl 类
		$this->CI->load->library('pxl');
		$objPHPExcel = new PHPExcel();
		$objPHPExcel->getProperties()->setTitle("title")->setDescription("description");
		$objPHPExcel->setActiveSheetIndex(0);

		//文件内容标题标题栏
		$objPHPExcel->getActiveSheet()->setCellValue("A1", $title);

		//数据标题栏
		foreach($headline as $k=>$v)
		{
			$cellname = $this->_getCellName($k);
	    $objPHPExcel->getActiveSheet()->setCellValue($cellname."2", $v);
		}

		//数据栏
		foreach($data as $k=>$v)
		{
			$i = 1;
			foreach($v as $dk=>$dv)
			{
				$cellname = $this->_getCellName($i);
				$objPHPExcel->getActiveSheet()->setCellValue($cellname.$k, $dv);
				$i++;
			}
		}

		// 产生 Excel 2007 文件头
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="'.$file_name.'"');
		header('Cache-Control: max-age=0');

		// 生成 Excel 2007 文件
		$objWriter = IOFactory::createWriter($objPHPExcel, "Excel2007");
		$objWriter->save('php://output');
		exit;
	}

	//Execl 数字到列名转换
	function _getCellName($num)
	{
		$this->CI =& get_instance();
		$cellArray = $this->CI->config->item("cell_array");

		$f = ($num<=26) ? 0 : floor($num/26); //余数
		$d = ($num == 26*$f) ? 26 : $num-(26*$f);
		
		if($f < 1)
		{
			$cellname = $cellArray[$num];
		}
		else
		{
			if($f > 1 && $num-(26*$f)==0)
			{
				$cellname = $cellArray[$f-1].$cellArray[$d];
			}
			else
			{
				$cellname = $cellArray[$f].$cellArray[$d];
			}
		}
		return $cellname;
	}
    
	/**
	*
	* 根据键入的域名返回系统号
	*
	* @access public
	* @param 空
	*/
	function getSys()
	{
		$this->CI =& get_instance();

		//初始化必要参数
		$domain = $this->CI->config->item("domain");
		$q = $this->CI->db->query("SELECT `id` FROM `ip_admin_domain` WHERE `domain` = '" . $domain . "' AND status='1' ");
		$sysArr = $q->result();
		if(!$sysArr)
		{
			//如果失败，记录操作日志
			$this->systemLog('90000');
			show_error(_('Error! systemd load faild!'));
		}
		else
		{
			//如果成功，返回系统ID
			$sys = $sysArr[0]->id;
			return $sys;
		}
		return false;
	}
    
	/**
	*
	* 根据系统号返回站点信息
	*
	* @access public
	* @param id 系统号
	*/
	function getOneSiteInfo($id)
	{
		if(!$id){return false;}
		$this->CI =& get_instance();
		$q = $this->CI->db->query("SELECT * FROM ip_admin_domain WHERE id = '" . $id . "' LIMIT 1 ");
		$obj_res = $q->result();
		$arr_res = $obj_res[0];
		return $arr_res;
	}

	/**
	*
	* 记录系统操作日志
	*
	* @access public
	* @param log_code 日志代码
	* @param param 操作对象
	*/
	function systemLog($log_code="90002",$param="")
	{
		$this->CI =& get_instance();

		//初始化必要参数
		$adminid = !$this->CI->session->userdata('adm_uid') ? '' : $this->CI->session->userdata('adm_uid');
		$ip = $this->CI->input->ip_address();
		$url = str_replace("http://".$_SERVER['HTTP_HOST'],'',current_url());

		//存储操作日志
		$now_time = date("Y-m-d H:i:s");
		$q = $this->CI->db->query("INSERT INTO `ip_system_log` (`log_code`,`admin_id`,`ip`,`act_time`,`url`,`param`) VALUE('".$log_code."','".$adminid."','".$ip."','".$now_time."','".$url."','".$param."') ");
	}

	/**
	 * 判断管理员对某一个操作是否有权限。
	 *
	 * 根据当前对应的action_code，然后再和管理员的action_list做匹配，以此来决定是否可以继续执行。
	 * @param     string    $priv_str    操作对应的priv_str
	 * @return true/false
	 */
	function admin_priv($priv_str)
	{
		$this->CI =& get_instance();
		$this->CI->load->model('user/approve_model');
		$rid = $this->CI->session->userdata('adm_rid');
		if ($rid == 0)
		{
			return true;
		}
		
		//获取管理员操作权限
		$adm_action_list = $this->CI->approve_model->getActionList($rid);
		$url = !$_SERVER["HTTP_REFERER"] ? '/welcome/' : $_SERVER["HTTP_REFERER"];
		if (!in_array($priv_str,$adm_action_list))
		{
			show_msg(_("没有操作权限, 正在返回，请稍候..."), $url);
			return false;
		}
		else
		{
			return true;
		}
	}

	/**
	 * 判断链接菜单显示权限。
	 *
	 * @param     string    $priv_str    操作对应的权限名
	 * @param     string    $url    操作链接
	 * @param     string    $act_name    操作名称
	 * @param     string    $flag    标识 1：控制单条菜单 2：控制菜单模块
	 * @return true/false
	 */
	function display_power($priv_str,$url='',$act_name='',$flag=1,$attr='',$rep_domain=1)
	{
		$this->CI =& get_instance();
		$this->CI->load->model('user/approve_model');
		$rid = $this->CI->session->userdata('adm_rid');
		if ($rid == 0)
		{
			if($flag == 1 && !empty($url) && !empty($act_name)){
				if(!$rep_domain){
					echo "<a href='".$url."' " . $attr . ">".$act_name."</a>";
				}else{
					echo anchor($url,$act_name,$attr);
				}
			}else{
				return true;
			}
		}
		
		//获取管理员操作权限
		$adm_action_list = $this->CI->approve_model->getActionList($rid);
		if (!in_array($priv_str,$adm_action_list))
		{
			return false;
		}
		else
		{
			if($flag == 1 && !empty($url) && !empty($act_name)){
				if(!$rep_domain){
					echo "<a href='".$url."' " . $attr . ">".$act_name."</a>";
				}else{
					echo anchor($url,$act_name,$attr);
				}
			}elseif($flag == 2){
				return true;
			}else{
				return false;
			}
		}
	}

	/**
	 * 判断input菜单显示权限。
	 *
	 * @param     string    $priv_str    操作对应的权限名
	 * @param     string    $form    操作表单
	 * @param     string    $flag    标识 1：控制单条表单 2：控制表单模块
	 * @return true/false
	 */
	function display_form_power($priv_str,$form,$flag=1)
	{
		$this->CI =& get_instance();
		$this->CI->load->model('user/approve_model');
		$rid = $this->CI->session->userdata('adm_rid');
		if ($rid == 0)
		{
			if($flag == 1 && !empty($form)){
				echo $form;
			}else{
				return true;
			}
		}
		
		//获取管理员操作权限
		$adm_action_list = $this->CI->approve_model->getActionList($rid);
		if (!in_array($priv_str,$adm_action_list))
		{
			return false;
		}
		else
		{
			if($flag == 1 && !empty($form)){
				echo $form;
			}elseif($flag == 2){
				return true;
			}else{
				return false;
			}
		}
	}
	
	/**
	*
	* 取得文件大小
	*
	* @access public
	* @param size 尺寸
	*/
	function get_size($size) 
	{
		if($size < 1024) 
		{
			return $size.'B';
		}
		else if($size < 1048576) 
		{
			return round($size/1024,2).'KB';
		}
		else if($size < 1073741824) 
		{
			return round($size/1048576,2).'MB';
		}
		else 
		{
			return round($size/1073741824,2).'GB';
		}
	}
	
	/**
	*
	* 将IP转换成数字
	*
	* @access public
	* @param ip IP
	*/
	function ipToInt($ip)
	{
		$array = explode('.',$ip);
		$int = ($array[0] * 256*256*256) + ($array[1]*256*256) + ($array[2]*256) + $array[3];
		return $int;
	}

	/**
	*
	* 将IP转换成真实地址
	*
	* @access public
	* @param ip IP
	*/
	function ip2location($ip)
	{
		if(!$ip){return "&nbsp;";}
		$this->CI =& get_instance();
		$intIp = $this->ipToInt($ip);
		$q = $this->CI->db->query("SELECT region,point FROM `ip_ipdata` WHERE s_ipdata <= ".$intIp." AND ".$intIp." <= e_ipdata ");
		$res = $q->result();
		return !$res ? "&nbsp;" : $res[0]->region.$res[0]->point;
	}

	/**
	*
	* 获取系统配置值
	*
	* @access public
	* @param sys 系统号
	* @param var 变量名
	*/
	function getVal($sys,$var)
	{
		$this->CI =& get_instance();

		$settings = $this->CI->config->item('sys_settings');//配置列表
		$var_arr = empty($settings[$sys]['var']) ? array() : $settings[$sys]['var'];
		$arr_check = in_array( $var, $var_arr); //检测变量名是否存在于数组
		if($arr_check){
			//检测变量名是否存在于数据库
			$q = $this->CI->db->query("SELECT var FROM ip_settings WHERE var ='".$var."' AND sys = '".$sys."'");
			$row = $q->result();
			if($row){
				$res = $row[0]->var;
			}else{
				$res = '';
			}
			if($res)
			{
				$q1 = $this->CI->db->query("SELECT val FROM ip_settings WHERE var ='".$var."' AND sys = '".$sys."'");
				$row1 = $q1->result();
				$res1 = $row1[0]->val;
				return $res1;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}

	/**
	*
	* 获取属性名
	*
	* @access public
	* @param  kid 属性编号
	*/
	function getAttrName($kid)
	{
		$this->CI =& get_instance();
		if(!$kid){
			return "&nbsp;";		
		}
		$q = $this->CI->db->query("SELECT name FROM ip_keylib WHERE id ='".$kid."' limit 1 ");
		$row = $q->result();
		if(!empty($row)){
			$res = $row[0]->name;
		}else{
			$res = "&nbsp;";
		}
		return $res;
	}

	/**
	*
	* 获取属性别名
	*
	* @access public
	* @param  kid 属性编号
	* @param  lang 属性语言
	*/
	function getAttrAlias($kid,$lang)
	{
		$this->CI =& get_instance();
		if(!$kid || !$lang){
			return "&nbsp;";		
		}
		$q = $this->CI->db->query("SELECT alias FROM ip_keylib_alias WHERE kid ='".$kid."' AND language ='".$lang."' limit 1 ");
		$res = $q->result();
		$name = $res[0]->alias;
		if(empty($name)){
			$q = $this->CI->db->query("SELECT name FROM ip_keylib WHERE id='".$kid."' ");
			$res = $q->result();
			$name = $res[0]->name;			
		}
		return !$name ? "&nbsp;" : $name;
	}

	/**
	*
	* 向iQuick系统发送请求
	*
	* @url iQuick的接口url
	* @data 向iQuick传送的数组数据
	*/
	function http_post ($url, $data)
	{
		$data_url = http_build_query ($data);
		$data_len = strlen ($data_url);

		return array (
						'content'=>@file_get_contents ($url, false, stream_context_create (array ('http'=>array ('method'=>'POST'
						, 'header'=>"Connection: close\r\nContent-Length: $data_len\r\n"
						, 'content'=>$data_url
						)))), 
						'headers'=>$http_response_header
				);
	}

	/**
	*
	* 编辑会员积分明细
	*
	* @access public
	* @param sys 系统编号
	* @param uid 会员编号 
	* @param point 增减积分值 
	* @param code 积分变动原因代码
	* @param param 积分变动原因附加值(如引发积分增加的项目编号)
	* @param note 积分变动备注说明
	* @param operator 积分变动操作者
	* @param point_fetch 加分规则：1:即时加分 2:后续加分
	*/
	function updMemberPoint($sys,$uid,$point,$code,$operator,$point_fetch='1',$param='',$note='')
	{
		$this->CI =& get_instance();
		$point = !$point ? 0 : $point;

		//预防本次积分变动后会员积分总额为负数
		$this->CI->load->model('member/member_management_model');
		$member_point_sum = $this->CI->member_management_model->getMemberPointSumDetail("uid",$uid);
		if($member_point_sum && $member_point_sum > 0)
		{
			if( $member_point_sum + ($point) < 0) { $point = 0; }
		}

		//创建积分编辑明细记录
		$q_detail = $this->CI->db->query("INSERT INTO ip_members_point_detail(`sys`,`uid`,`point`,`point_change_code`,`point_change_param`,`point_change_note`,`point_change_operator`,`point_fetch`) VALUES ('".$sys."','".$uid."','".$point."','".$code."','".$param."','".$note."','".$operator."','".$point_fetch."')");

		//如果即时加分,则编辑 usable_point 值
		if($point_fetch == '1') { $update_usable_point = ",`usable_point`=`usable_point`+(".$point.")"; }
		
		//如果扣除积分或者返回积分，则编辑 used_point 值
		if($point < 0 || $code == '402' || $code == '403'){
			$update_point_plus = ",`used_point`=`used_point`+(".$point.")";
		}

		//编辑会员积分总额
		$q_sum = $this->CI->db->query("UPDATE `ip_members_point_sum` SET `total_point`=`total_point`+".$point.$update_usable_point.$update_point_plus." WHERE `uid`='".$uid."'");

		return !$q_detail || !$q_sum ? false : true;
	}

	/**
	*
	* 获取管理员英文名
	*
	* @access public
	* @param  id 管理员编号
	*/
	function getAdminNameById($id)
	{
		if(!$id){return "&nbsp;";}
		$this->CI =& get_instance();
		$q = $this->CI->db->query("SELECT en_name FROM ip_admin WHERE id='".$id."'");
		$row = $q->result();
		return !$row ? "&nbsp;" : $row[0]->en_name;		
	}

	/**
	*
	* 获取管理员登录地址
	*
	* @access public
	* @param  id 管理员编号
	*/
	function getAdminLoginLocation($id)
	{
		if(!$id){return "&nbsp;";}
		$this->CI =& get_instance();
		$q = $this->CI->db->query("SELECT region,point FROM `xfunc_admin_list` WHERE id='".$id."' ");
		$res = $q->result();
		return !$res ? "&nbsp;" : $res[0]->region.$res[0]->point;
	}

	/**
	*
	* 操作日志
	*
	* @access public
	* @param  log_code 日志代码
	* @param  id 操作对象
	*/
	function _syslog( $log_code, $id = '' ){
		$this->CI =& get_instance();
		if( ( $this->CI->db->affected_rows() ) > 0 ){
				$this->systemLog( $log_code, $id );
				return false;
		}else{
				return true;
		}
	}

	/**
	*
	* POST传输删除的数据
	*
	* @access public
	* @param  item_del_str 需要删除的数据，按“，”分割的字符串
	* @param  url 跳转地址
	*/
	function _postDeleteDiv($item_del_str,$url,$back_url=""){
		return "<html><body onload='document.getElementById(\"delete\").submit();'><form method='POST' action='".$url."' name='delete' id='delete'>
					<input type='hidden' name='back_url' value='".$back_url."'>
					<input type='hidden' name='item_del_str' value='".$item_del_str."'>
				</form></body></html>";
	}

	/**
	*
	* 获取数据库信息
	*
	* @access public
	*/
	function getDbSize()
	{
		$this->CI =& get_instance();
		$q = $this->CI->db->query("SELECT length FROM `xfunc_db_info` WHERE id='1'");
		$res = $q->result();
		return !$res ? false : $res[0]->length;	
	}

	/**
	*
	* 获取站点当前有效会员总数
	*
	* @access public
	*/
	function getValidUserNum($sys)
	{
		if($sys){
			$this->CI =& get_instance();
			$q = $this->CI->db->query("SELECT total_count FROM `xfunc_members_sum` WHERE sys='".$sys."'");
			$res = $q->result();
			return !$res ? false : $res[0]->total_count;	
		}
	}

	/**
	* 发送邮件(伊業科技)
	*
	* 发送邮件
	*
	* @access public
	*/
	function third_party_sendmail($sys,$to,$subject,$msg)
	{
		$this->CI =& get_instance();
		$this->CI->load->library('email');
		$config['protocol'] = 'smtp';
		$config['smtp_host'] = '114.80.76.157';
		$config['smtp_user'] = 'survey@ipanelonline.com';
		$config['smtp_pass'] = 'jdkjekkreht';
		$config['smtp_port'] = '25';
		$config['smtp_timeout'] = '5';
		$config['mailtype'] = 'html';
		$config['wordwrap'] = TRUE;

		$this->CI->email->initialize($config);
		$from = $this->getVal($sys, "email_from");
		$from_name = $this->getVal($sys, "email_from_name");
		$this->CI->email->from($from, $from_name);
		$this->CI->email->to($to); 
		$this->CI->email->reply_to('survey@ipanelonline.com', 'iPanelOnline');
		$this->CI->email->subject($subject);
		$this->CI->email->message($msg); 

		return $this->CI->email->send();
	}

	/**
	* 发送邮件(Postmark)
	*
	* 发送邮件
	*
	* @access public
	*/
	function postmark_sendmail($sys,$to,$subject,$msg)
	{
		$this->CI =& get_instance();
		$this->CI->load->library(array('email', 'postmark'));
		$this->CI->email->initialize($config);

		$from = $this->getVal($sys, "email_from");
		$from_name = $this->getVal($sys, "email_from_name");

		$this->CI->postmark->from("onlinew-survey@ipanelonline.com", "iPanelonline");
		$this->CI->postmark->to($to); 
		$this->CI->postmark->reply_to("onlinew-survey@ipanelonline.com", "iPanelOnline");
		$this->CI->postmark->subject($subject);
		$this->CI->postmark->message($msg); 

		return $this->CI->postmark->send();
	}

	/**
	* 获取IP地址
	* 
	* @access public
	*/
	function getip(){
		if(getenv('HTTP_X_FORWARDED_FOR') != '') {
			$client_ip = (!empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : ( (!empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : $REMOTE_ADDR);
			$entries = explode(',', getenv('HTTP_X_FORWARDED_FOR'));
			reset($entries);
			while (list(, $entry) = each($entries)) {
				$entry = trim($entry);
					if (preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $entry, $ip_list) ) {
						$private_ip = array('/^0\./', '/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/', '/^10\..*/', '/^224\..*/', '/^240\..*/');
						$found_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);
					
					if ($client_ip != $found_ip) {
						$client_ip = $found_ip;
						break;
					}
				}
			}
		}else{
			$client_ip = (!empty($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : ((!empty($_ENV['REMOTE_ADDR'])) ? $_ENV['REMOTE_ADDR'] : $REMOTE_ADDR);
		}
		return $client_ip;
	}

	/**
	*
	* 根据权限判断是否输出菜单
	*
	* @access public
	* @param  power 权限名
	* @param  act 操作
	* @param  p_name_st 控制器定义操作变量
	* @param  class 样式
	* @param  url 路径
	* @param  act_act 菜单中文名
	*/
	function printMenu($power,$act,$p_name_st,$class,$url,$act_cn,$attr='')
	{
		if($this->display_power($power,'','',2)){
			echo "<li";
			if( $p_name_st == $act ){ 
				echo ' class="'.$class.'"'; 
			}
			echo '>' . anchor($url,$act_cn,$attr) . '</li>';
		}
	}

	/**
	*	处理返回，成功或失败时
	* @access $rs	返回结果
	* @param  $suc_url 成功跳转链接
	* @param  $fail_url 失败跳转链接
	*/
	function getBack($rs,$suc_url,$fail_url){
		if($rs){
			show_msg( _('操作成功,正在返回，请稍候...'), site_url( $suc_url ) );
		}else{
			show_msg( _('操作失败,正在返回，请稍候...'), site_url( $fail_url ) );
		}
	}

	/**
	*	本月第几周
	* @access $addtime	需要处理的时间
	*/
	function checkweek($addtime)
	{
			if(empty($addtime)){return false;}
			$addtime = strtotime($addtime);
			$month = date('m', $addtime); // 获取本月
			$year = date('Y', $addtime); // 获取本年
			$day = date('d', $addtime); // 获取天数
			$firstday = date('w', mktime(0, 0, 0, $month, 1, $year)); //本月1号星期数
			$firstweek = 7 - $firstday; // 第1周天数
			//$week = ceil(($day - $firstweek) / 7) + 1; 
			$week = ceil(($day - $firstweek) / 7); 
			return $month.'月第' . $week . '周';
	}
	
	//设置时区
	function setTimeoffset($sys)
	{
		$this->CI =& get_instance();
		$timeoffset = $this->getVal($sys,'timeoffset');
		$timeoffset_arr = $this->CI->config->item('timeoffset');
		$timeoffset = $timeoffset_arr[$timeoffset];
		if(phpversion() > '5.1') {
			@date_default_timezone_set('Etc/GMT'.($timeoffset > 0 ? '-' : '+').(abs($timeoffset)));
		}	
	}

	/**
	*	获取违规信息
	* @access $rs	返回结果
	* @param  $lang 语言
	*/
	function getDenyReason($lang)
	{
		if(!$lang){return "&nbsp;";}
		$this->CI =& get_instance();
		$q = $this->CI->db->query("SELECT did,reason FROM ip_deny_reason_info WHERE lang='".$lang."'");
		$row = $q->result();
		if(!$row){
			return "&nbsp;";
		}else{
			foreach($row as $k => $v){
				$res[$v->did] = $v->reason;
			}
			return $res;
		}
	}

	/**
	*	获取黑名单原因
	* @access $rs	返回结果
	* @param  $lang 语言
	*/
	function getBlacklistReason($lang)
	{
		if(!$lang){return "&nbsp;";}
		$this->CI =& get_instance();
		$q = $this->CI->db->query("SELECT bid,reason FROM ip_blacklist_reason_info WHERE lang='".$lang."'");
		$row = $q->result();
		if(!$row){
			return "&nbsp;";
		}else{
			foreach($row as $k => $v){
				$res[$v->bid] = $v->reason;
			}
			return $res;
		}
	}

	/**
	*	获取咨询类别
	* @access $rs	返回结果
	* @param  $lang 语言
	*/
	function getConsultType($lang)
	{
		if(!$lang){return "&nbsp;";}
		$this->CI =& get_instance();
		$q = $this->CI->db->query("SELECT cid,content FROM ip_consult_type_info WHERE lang='".$lang."'");
		$row = $q->result();
		if(!$row){
			return "&nbsp;";
		}else{
			foreach($row as $k => $v){
				$res[$v->cid] = $v->content;
			}
			return $res;
		}
	}

	/**
	*	获取信体类别
	* @access $rs	返回结果
	* @param  $lang 语言
	*/
	function getEmailType($lang)
	{
		if(!$lang){return "&nbsp;";}
		$this->CI =& get_instance();
		$q = $this->CI->db->query("SELECT eid,content FROM ip_email_type_info WHERE lang='".$lang."'");
		$row = $q->result();
		if(!$row){
			return "&nbsp;";
		}else{
			foreach($row as $k => $v){
				$res[$v->eid] = $v->content;
			}
			return $res;
		}
	}

	/**
	*	获取信体类别
	* @access $rs	返回结果
	* @param  $lang 语言
	*/
	function getEmailTypeName($eid,$lang)
	{
		if(!$lang || !$eid){return "&nbsp;";}
		$this->CI =& get_instance();
		$q = $this->CI->db->query("SELECT content FROM ip_email_type_info WHERE lang='".$lang."' AND eid='".$eid."' LIMIT 1");
		$row = $q->result();
		if(!$row){
			return "&nbsp;";
		}else{
			$res = $row[0]->content;
			return !$res ? "&nbsp;" : $res;
		}		
	}

	/**
	*	用linux命令拷贝文件夹及文件
	* @access 返回true或false
	* @param  $source 源目录名
	* @param  $destination 目的目录名
	*/
	function xCopy($source, $destination){
		if(!$source || !is_dir($source)){return false;}
		if(!is_dir($destination)){
			exec("cp -R $source $destination");
			return true;
		}else{
			return 2;
		}
	}

	/**
	*	根据表名返回该表所有字段信息
	* @access rs	返回结果
	* @param  tab	表名
	*/
	function getTabelAllComment($tab)
	{
		if(!$tab){return "&nbsp;";}
		$this->CI =& get_instance();
		$q = $this->CI->db->query("	show full fields from ".$tab." ");
		$row = $q->result();
		if(!$row){
			return "&nbsp;";
		}else{
			$res = $row;
			return !$res ? "&nbsp;" : $res;
		}		
	}

	/**
	*
	* 获系统后台邮件信体内容
	*
	* @type 信体类别
	* @lang 当前使用语言
	* @sys_id 系统编号
	*/
	function getMailContent($type,$lang)
	{
		$this->CI =& get_instance();
		$q = $this->CI->db->query("SELECT mail_subject,mail_content FROM `ip_email_text` a,`ip_email_id` b WHERE a.lang = '".$lang."' AND  b.mail_type = '".$type."' AND a.in_use = '1' AND a.eid =b.id ");
		$res = $q->result();
		return $res[0];
	}
}

/* End of file Myfunctions.php */
/* Location: ./system/application/management/libraries/Myfunctions.php */